home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14895 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  63 lines

  1. Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather
  2. Path: newsfeed.acns.nwu.edu!ftpbox!mothost!schbbs!news
  3. From: shang@corp.mot.com (David L. Shang)
  4. Subject: Re: What Should An Exception Handling Do? -- Clarification of rules
  5. Reply-To: shang@corp.mot.com
  6. Organization: MOTOROLA 
  7. Date: Tue, 2 Apr 1996 15:47:22 GMT
  8. Message-ID: <1996Apr2.154722.29777@schbbs.mot.com>
  9. References: <vwjg2ao6hqp.fsf@osfb.aber.ac.uk>
  10. Sender: news@schbbs.mot.com (SCHBBS News Account)
  11. Nntp-Posting-Host: 129.188.128.126
  12.  
  13. In article <vwjg2ao6hqp.fsf@osfb.aber.ac.uk> pcg@aber.ac.uk (Piercarlo Grandi)  
  14. writes:
  15. > Therefore exception handling reduces to simply providing a mechanism by
  16. > which the *author* of a code segment provides a mechanism by which the
  17. > *user* of that code segment can specify additional cases, as for example
  18. > in:
  19. >     float sqrt(float n)
  20. >     {
  21. >       if
  22. >          n > 0 -> ...;
  23. >       [] n == 0 -> return 0;
  24. >       [] n < 0 -> return sqrt_negative(n);
  25. >       fi
  26. >     }
  27. > where the only difficulty is that sqrt_negative must be dynamically
  28. > scoped instead of statically scoped, for it must be redefinable by the
  29. > *user* of the procedure.
  30. > This again means that termination is the only possible outcome for this
  31. > case too.
  32.  
  33. Termination? When you execute:
  34.  
  35.     return sqrt_negative(n)
  36.  
  37. first,  you call "sqrt_negative" to get the result, then you do return
  38. to terminate. It is not the case that you first terminate then you call
  39. "sqrt_negative". Once your terminate, you can never go back.
  40.  
  41. If I write code like:
  42.  
  43.      float sqrt(float n)
  44.      {
  45.        if
  46.           n > 0 -> ...;
  47.        [] n == 0 -> return 0;
  48.        [] n < 0 -> { n1= sqrt_negative(n); return n1; }
  49.        fi
  50.      }
  51.  
  52. Is the program terminated at the point of calling "sqrt_negative"?
  53. This embedded exception handler exactly provides a resumption
  54. semantics, which, according to your previous analysis, is the
  55. only case that exception handling makes any sense(?).
  56.  
  57.  
  58. David Shang
  59.